layui.use(['layer', 'form', 'jquery'], function () {

    document.querySelector('#formLogin').addEventListener('submit', function (e) {
        e.preventDefault();
    }, false);

    var layer = layui.layer,
        form = layui.form(),
        $ = layui.jquery;

    form.on('submit(buttonSubmit)', function (data) {
        $.ajax({
            method: 'POST',
            url:'/login',
            data: data.field,
            success: function (json) {
                if (json.status) {
                    layer.msg('登录成功!');
                } else {
                    layer.msg('登录失败!');
                }
            },
            error: function () {
                layer.msg('网络错误!');
            }
        });
        return false;
    });
});
